//@ts-ignore
import start_play_wav from "./ring_data/start_player.wav";
//@ts-ignore
import stop_play_wav from "./ring_data/stop_player.wav";
//@ts-ignore
import start_record_wav from "./ring_data/start_record.wav";
//@ts-ignore
import stop_record_wav from "./ring_data/stop_record.wav";


export enum RingDataID {
    RING_PLAYER_START_ID,
    RING_PLAYER_STOP_ID,
    RING_RECORDER_START_ID,
    RING_RECORDER_STOP_ID
}

const wav_urls = [start_play_wav, stop_play_wav, start_record_wav, stop_record_wav];

export function weila_playRing(id: number): Promise<boolean> {
    let url = wav_urls[id];
    return new Promise<boolean>((resolve, reject) => {
        const audio = document.createElement('audio');
        audio.id = 'ring';
        audio.src = url;
        audio.preload = 'auto';
        audio.play().then(value => {
            console.log('播放成功')
            resolve(true);
        }).catch(reason => {
            console.log('播放失败', reason);
            reject('播放铃声失败');
        });
    });
}


